//
//  MainViewController.swift
//  ZZUIDemo
//
//  Created by 张文晏 on 2018/5/17.
//  Copyright © 2018年 Newcoretech. All rights reserved.
//

import UIKit


class MainViewController: UIViewController {
    
    struct CellItem {
        var title: String
        var vc: UIViewController
    }
    
    
    @IBOutlet weak var tableView: UITableView!
    
    var cellItems: [CellItem] = [
        CellItem(title: "Calendar", vc: CalendarDemoViewController()),
        CellItem(title: "HUD", vc: HUDDemoViewController()),
        CellItem(title: "NCButton", vc: NCButtonDemoViewController()),
        CellItem(title: "NCFilterBox", vc: FilterBoxDemoViewController()),
        CellItem(title: "NCTextView", vc: NCTextViewDemoViewController()),
        CellItem(title: "NumberButton", vc: NumberButtonDemoViewController()),
        CellItem(title: "PopoverView", vc: PopoverViewDemoViewController()),
        CellItem(title: "ScanSearch", vc: ScanSearchDemoViewController()),
        CellItem(title: "SearchTextField", vc: SearchTextFieldDemoViewController()),
        CellItem(title: "AnnularProgress", vc: AnnularProgressViewController()),
        CellItem(title: "PhotoBrowser", vc: PhtotoBrowserDemoViewController())
    ]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Demo"
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
    }
    
}

extension MainViewController: UITableViewDataSource {
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return cellItems.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell")!
        cell.selectionStyle = .none
        cell.textLabel?.text = cellItems[indexPath.row].title
        return cell
    }
    
}

extension MainViewController: UITableViewDelegate {
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let vc = cellItems[indexPath.row].vc
        navigationController?.pushViewController(vc, animated: true)
    }
    
}
